feat: add @constructive-io/fetch package#81
Merged
pyramation merged 1 commit intomainfrom Apr 28, 2026
Merged
Conversation
Isomorphic fetch wrapper that resolves *.localhost subdomains and preserves Host headers across Node.js and browsers. In Node.js, *.localhost URLs are handled via node:http/node:https (fixing DNS resolution + Host header). Everything else delegates to globalThis.fetch. In browsers, it's a passthrough. Zero dependencies. Designed to replace @constructive-io/node as the default fetch for generated SDK clients.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Merged
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
@constructive-io/fetchpackage — a lean isomorphic fetch wrapper that fixes*.localhostsubdomain handling in Node.js.Problem: Node.js has two issues with
*.localhostsubdomains that break local development with the Constructive GraphQL server's subdomain routing:fetch('http://auth.localhost:3000/')throwsENOTFOUND(nodejs/node#50871)Hostas forbidden and silently drops itSolution:
createFetch()returns a fetch function that:node:http/node:httpsfor*.localhostURLs (fixing DNS + Host header), delegates everything else toglobalThis.fetchglobalThis.fetchas-is (browsers handle*.localhostnatively)Zero dependencies. ~100 lines of source code. Designed to replace
@constructive-io/nodeas the default fetch for generated SDK clients (see constructive#1033).API
Review & Testing Checklist for Human
*.localhost→localhostrewrite + Host header injection works against a real PostGraphile server with subdomain routingglobalThis.fetchwithout modificationnode:httprequest handling covers all needed fetch options (method, headers, body, signal)Notes
require('node:http')rather than asyncimport()— works in CJS (the monorepo target) and avoids bundler analysis issuescreateFetch()is cached (singleton) — safe to call repeatedlyLink to Devin session: https://app.devin.ai/sessions/0e3a5bf6765a4c979b64ef786a813225
Requested by: @pyramation